/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.dao.hibernate;

import com.click.app.dao.OptionDao;
import com.click.app.model.Option;
import java.util.List;

/**
 *
 * @author israel
 */
public class OptionDaoHibernate extends GenericDaoHibernate<Option, Long> implements OptionDao {

    /**
     * Constructor to create a Generics-based version using Role as the entity
     */
    public OptionDaoHibernate() {
        super(Option.class);
    }

    public Option getOptionByName(String optionName){
        List options = getHibernateTemplate().find("from Option where name=?", optionName);
        if (options.isEmpty()) {
            return null;
        } else {
            return (Option) options.get(0);
        }
    }

    public void removeOption(String optionName){
        Object option = getOptionByName(optionName);
        getHibernateTemplate().delete(option);
    }
}
